# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=py3-pytest-benchmark
_pkgname=pytest-benchmark
pkgver=3.2.3
pkgrel=0
pkgdesc="A pytest fixture for benchmarking code"
url="https://github.com/ionelmc/pytest-benchmark"
arch="noarch !mips !mips64" # blocked by py3-py-cpuinfo
license="BSD-2-Clause"
depends="python3 py3-pytest py3-py-cpuinfo"
makedepends="py3-setuptools"
checkdepends="py3-pytest-xdist py3-freezegun py3-pygal py3-elasticsearch"
source="$_pkgname-$pkgver.tar.gz::https://github.com/ionelmc/pytest-benchmark/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	python3 setup.py build
}

check() {
	# install the package to test_install directory for testing
	python3 setup.py install --root="$builddir"/test_install

	# disable three tests that require aspectlib (needs packaging)
	# last test fails when run inside a git repository, see: https://github.com/ionelmc/pytest-benchmark/issues/163
	PYTHONPATH="$builddir"/test_install/usr/lib/python3.8/site-packages PATH="$builddir"/test_install/usr/bin:"$PATH" \
		pytest -v tests \
		--deselect tests/test_with_testcase.py::TerribleTerribleWayToWritePatchTests::test_foo2 \
		--deselect tests/test_with_weaver.py::test_weave_fixture \
		--deselect tests/test_with_weaver.py::test_weave_method \
		--deselect tests/test_utils.py::test_parse_elasticsearch_storage
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir" --skip-build
}

sha512sums="952dbe2a9af1ae5de966543eae3b4523a5418c8441785714cbb7a5d17697046f060befb4a40cf216526e2a9a63d91c598d65e65618bd78fc2d889c92cecbbe53  pytest-benchmark-3.2.3.tar.gz"
